<?php
namespace app\controller;

use app\BaseController;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;

class Cate extends BaseController
{
    public function list(): Json
    {
        try {
            $list = $this->M("category")->where('stat', 1)->select()->toArray();
            return pr(200, API_SUCCESS, $list);
        } catch (DataNotFoundException $e) {
            return pr(201, '没有数据');
        } catch (ModelNotFoundException $e) {
            return pr(202, '模型不存在');
        } catch (DbException $e) {
            return pr(203, $e->getMessage());
        }
    }
    public function index(): string
    {
        return 'Hello';
    }

}
